package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.ServiceStaff;
import com.example.admin.mapper.ServiceStaffMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ServiceStaffService {

    @Autowired
    private ServiceStaffMapper serviceStaffMapper;

    public List<ServiceStaff> getServiceStaffPage() {
      List<ServiceStaff> serviceStaffList=  serviceStaffMapper.getServiceStaffPage();
      return serviceStaffList;

    }

    public Result deleteById(Integer id) {

       int count= serviceStaffMapper.deleteById(id);
       if (count==0)
       {
           return Result.error("400","删除失败");
       }
       return Result.success("删除成功");
    }

    public Result addServiceStaff(ServiceStaff serviceStaff) {
      int count=  serviceStaffMapper.addServiceStaff(serviceStaff);
        if (count==0)
        {
            return Result.error("400","新增失败");
        }
        return Result.success("新增成功");
    }

    public Result editServiceStaffInfo(ServiceStaff serviceStaff) {

       int count= serviceStaffMapper.editServiceStaffInfo(serviceStaff);
        if (count==0)
        {
            return Result.error("400","更新失败");
        }
        return Result.success("更新成功");
    }

    public List<ServiceStaff> selectByName(String name) {
       List<ServiceStaff> serviceStaffList= serviceStaffMapper.selectByName(name);
       return serviceStaffList;
    }
}
